# -*- coding: utf-8 -*-

import time

from log.aiDpsLog import logger


class timemonitor(object):
    def __init__(self, codename):
        self.codename = codename

    def __enter__(self):
        self.starttime = time.perf_counter()

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.endtime = time.perf_counter()
        logger.info('%s execute time:%6.3fs' % (self.codename, (self.endtime - self.starttime)))
